<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>自定义属性的粒子效果</title>
  <style>
    body {
      margin: 0;
      overflow: hidden;
    }
    canvas {
      outline: none;
    }
  </style>
</head>
<body>
  <script type="x-shader/x-vertex" id="vertexShader">
    attribute float size;

    varying vec3 vColor;

    void main() {
      vColor = color;

      vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);

      gl_PointSize = size * (300.0 / -mvPosition.z);

      gl_Position = projectionMatrix * mvPosition;
    }
  </script>

  <script type="x-shader/v-fragment" id="fragmentShader">
    uniform sampler2D pointTexture;

    varying vec3 vColor;

    void main() {
      gl_FragColor = vec4(vColor, 1.0);

      gl_FragColor = gl_FragColor * texture2D(pointTexture, gl_PointCoord);
    }
  </script>

  <script src="./_custom_attribute_particles.js" type="module"></script>
</body>
</html>